﻿Public Class FMenu
    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()

        ' Add any initialization after the InitializeComponent() call.
        Me.Text = My.Settings.NamaAplikasi & " [Menu Utama]"
    End Sub

    Private Sub KelasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KelasToolStripMenuItem.Click
        Dim _FMKelas As New FMKelas
        With _FMKelas
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
        End With
    End Sub

    Private Sub GuruToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuruToolStripMenuItem.Click
        Dim _fmGuru As New FMGuru
        With _fmGuru
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
        End With
    End Sub

    Private Sub SemesterToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SemesterToolStripMenuItem.Click
        Dim _fmSemester As New FMSemester
        With _fmSemester
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
        End With
    End Sub

    Private Sub PerwalianKelasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PerwalianKelasToolStripMenuItem.Click
        Dim _fmWaliKelas As New FMWaliKelas
        With _fmWaliKelas
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
        End With
    End Sub

    Private Sub MataPelajaranToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MataPelajaranToolStripMenuItem.Click
        Dim _fmMataPelajaran As New FMMataPelajaran
        With _fmMataPelajaran
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
        End With
    End Sub

    Private Sub GuruMengajarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GuruMengajarToolStripMenuItem.Click
        ''Dim _fmGuruMengajar As New FMGuruMengajar
        ''_fmGuruMengajar.Show()
        'Dim _fmMengajar As New FMMengajar
        'With _fmMengajar
        '    .MdiParent = Me
        '    '.WindowState = FormWindowState.Maximized
        '    .Show()
        'End With
    End Sub

    Private Sub PengaturanAwalToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PengaturanAwalToolStripMenuItem.Click
        Dim _fnPengaturanAwal As New FMPengaturanAwal
        _fnPengaturanAwal.ShowDialog()
    End Sub

    Private Sub PendaftaranToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PendaftaranToolStripMenuItem.Click
        Dim _ftPendaftaran As New FTPendaftaran
        With _ftPendaftaran
            .MdiParent = Me
            .Show()
            '.WindowState = FormWindowState.Maximized
        End With
    End Sub

    Private Sub PekerjaanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PekerjaanToolStripMenuItem.Click
        Dim _fmPekerjaan As New FMPekerjaan
        _fmPekerjaan.MdiParent = Me
        '_fmPekerjaan'.WindowState = FormWindowState.Maximized
        _fmPekerjaan.Show()
    End Sub

    Private Sub SiswaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SiswaToolStripMenuItem.Click
        Dim _fmSiswa As New FMSiswa
        With _fmSiswa
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
            '.WindowState = FormWindowState.Maximized
        End With
    End Sub

    Private Sub PembagianKelasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PembagianKelasToolStripMenuItem.Click
        Dim _ftpembagian As New FTPembagianKelas
        _ftpembagian.Show()
    End Sub

    Private Sub PenilaianToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PenilaianToolStripMenuItem.Click
        'Dim _ftPenilaian As New FTPenilaian
        'With _ftPenilaian
        '    .MdiParent = Me
        '    .Show()
        '    '.WindowState = FormWindowState.Maximized
        'End With

        'Dim _foPenilaian As New FOPenilaian
        '_foPenilaian.ShowDialog()

        Dim _fopenilaian As New FOPenilaianSiswa(Me)
        _fopenilaian.ShowDialog()
    End Sub

    Private Sub MenuColoring(ByVal ctlMenu As Object)

        If TypeOf ctlMenu Is MenuStrip Then
            For Each amenu As ToolStripMenuItem In ctlMenu.Items
                amenu.BackColor = Color.FromArgb(72, 153, 12)
                amenu.ForeColor = Color.White
                If amenu.HasDropDownItems Then
                    MenuColoring(amenu)
                End If
            Next
        ElseIf TypeOf ctlMenu Is ToolStripDropDownItem Then
            For Each anitem As ToolStripDropDownItem In ctlMenu.DropDownItems
                anitem.BackColor = Color.FromArgb(72, 153, 12)
                anitem.ForeColor = Color.White

                If anitem.HasDropDownItems Then
                    MenuColoring(anitem)
                End If
            Next
        End If


    End Sub

    Private Sub FMenu_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'set drop down color
        MenuColoring(MenuStrip1)
        'For Each amenu As ToolStripMenuItem In MenuStrip1.Items
        '    amenu.BackColor = Color.FromArgb(72, 153, 12)
        '    For Each anitem As ToolStripDropDownItem In amenu.DropDownItems
        '        anitem.BackColor = Color.FromArgb(72, 153, 12)
        '        anitem.ForeColor = Color.White

        '        If anitem.HasDropDownItems Then
        '            For Each danitem As ToolStripDropDownItem In anitem.DropDownItems
        '                danitem.BackColor = Color.FromArgb(72, 153, 12)
        '                danitem.ForeColor = Color.White
        '            Next
        '        End If
        '    Next
        'Next


        'set tutup toolstrip backcolor
        With TutupToolStripMenuItem
            .BackColor = Color.FromArgb(61, 131, 10)
            .ForeColor = Color.White
        End With


        'If MasterToolStripMenuItem.DropDownItems(0).BackColor <> Color.FromArgb(72, 153, 12) Then
        '    For Each a As ToolStripDropDownItem In MasterToolStripMenuItem.DropDownItems
        '        a.BackColor = Color.FromArgb(72, 153, 12)
        '        a.ForeColor = Color.White
        '    Next
        'Else
        '    MsgBox("udah")
        'End If

        'tampilkan waktu sistem
        'Label1.Text = Now.ToShortDateString & " [" & Format(Now.Date, "HH:mm:ss") & "]"

        'set background color
        Dim ctl As Control
        Dim ctlMDI As MdiClient

        ' Loop through all of the form's controls looking
        ' for the control of type MdiClient.
        For Each ctl In Me.Controls
            Try
                ' Attempt to cast the control to type MdiClient.

                ctlMDI = CType(ctl, MdiClient)
                ' Set the BackColor of the MdiClient control.
                ctlMDI.BackColor = Me.BackColor


            Catch exc As InvalidCastException
                ' Catch and ignore the error if casting failed.
            End Try
        Next

    End Sub

    Private Sub RegistrasiToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RegistrasiToolStripMenuItem.Click
        'Dim _ftPendaftaran As New FTPendaftaran
        'With _ftPendaftaran
        '    .MdiParent = Me
        '    .Show()
        '    '.WindowState = FormWindowState.Maximized
        'End With
        Dim _ftPendaftaran As New FTInputSiswa
        With _ftPendaftaran
            .MdiParent = Me
            .Show()
            .WindowState = FormWindowState.Maximized
        End With
    End Sub

    Private Sub BagiKelasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BagiKelasToolStripMenuItem.Click
        Dim _fbagi As New FTBagiSiswa
        With _fbagi
            .MdiParent = Me
            .Show()
            '.WindowState = FormWindowState.Maximized
        End With
    End Sub

    Private Sub MengajarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MengajarToolStripMenuItem.Click
        Dim _fmengajar As New FMGuruMengajar
        With _fmengajar
            .MdiParent = Me
            '.WindowState = FormWindowState.Maximized
            .Show()
        End With
    End Sub

    Private Sub MasterToolStripMenuItem_DropDownClosed(sender As Object, e As System.EventArgs) Handles MasterToolStripMenuItem.DropDownClosed, TransaksiToolStripMenuItem.DropDownClosed, WindowsToolStripMenuItem.DropDownClosed
        'set forecolor to white
        sender.ForeColor = Color.White
    End Sub

    Private Sub MasterToolStripMenuItem_DropDownOpened(sender As Object, e As System.EventArgs) Handles MasterToolStripMenuItem.DropDownOpened, TransaksiToolStripMenuItem.DropDownOpened, WindowsToolStripMenuItem.DropDownOpened
        'set forecolor to black
        sender.ForeColor = Color.Black

        'set window dropdown items
        If sender Is WindowsToolStripMenuItem Then
            For Each anitem As ToolStripDropDownItem In sender.DropDownItems
                anitem.BackColor = Color.FromArgb(72, 153, 12)
                anitem.ForeColor = Color.White
            Next
        End If
    End Sub

  
    Private Sub TutupToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles TutupToolStripMenuItem.Click
        Me.Close()
    End Sub

    Private Sub NilaiSiswaToolStripMenuItem_Click(sender As System.Object, e As System.EventArgs) Handles NilaiSiswaToolStripMenuItem.Click
        Dim _fnilai As New FMNilai
        With _fnilai
            .MdiParent = Me
            .Show()
        End With
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ToolStripStatusJam.Text = Now.ToString("HH:mm:ss")
    End Sub
End Class